<?php
class M_print_fees Extends MY_Model
{
	public function get_student_fees($id)
	{
		$sql = "SELECT sef_fee_name,
					   sef_fee_rate,
					   is_tuition_fee,
					   is_other_fee,
					   is_misc_fee,
					   is_uniform_fee,
					   is_elective_fee
				FROM student_enrollment_fees 
				WHERE sef_enrollment_id = ? 
				AND sef_schoolyear_id = ?
				ORDER BY is_tuition_fee DESC";
		$query = $this->db->query($sql,array($id,$this->c_sy->id));
		return $query->num_rows() >=1 ? $query->result() : FALSE;
	}
	
	public function get_payments_made_with_breakdown($id)
	{
		$sql = "SELECT 
					   spr.spr_id,
					   spr.spr_or_no,
					   spr.spr_remarks,
					   spr.spr_ammt_paid,
					   spr.spr_payment_date,
					   spb.spb_fee_name,
					   spb.spb_amount_paid,
					   spb.spb_remaining_balance,
					   spb.spb_is_tuition_fee,
					   spb.spb_is_other_fee,
					   spb.spb_is_elective_fee,
					   spb.spb_is_uniform_fee,
					   spb.spb_is_misc_fee
				FROM student_payment_records spr
				LEFT JOIN student_payment_breakdown spb ON spb.spb_spr_id = spr.spr_id
				WHERE spr_enrollment_id = ?
				AND spr_schoolyear_id = ?
				AND spr_is_deleted = 0
				ORDER BY spr_created ASC";
		$query = $this->db->query($sql,array($id,$this->c_sy->id));
		return $query->num_rows() >=1 ? $query->result() : FALSE;
	}
	
	public function get_payments_made($id)
	{
		$sql = "SELECT spr.spr_or_no,
					   spr.spr_remarks,
					   spr.spr_ammt_paid,
					   spr.spr_payment_date
				FROM student_payment_records spr
				WHERE spr_enrollment_id = ?
				AND spr_schoolyear_id = ?
				AND spr_is_deleted = 0
				ORDER BY spr_created ASC";
		$query = $this->db->query($sql,array($id,$this->c_sy->id));
		return $query->num_rows() >=1 ? $query->result() : FALSE;
	}
}